<?php

class DB_FOLLOWS extends ORM_Table {
    
    static protected $table_name = 'follows';
    
    static public function getTableName($params = null) {
        return self::$table_name;
    }
    
    static function batchSave($weibo_id, $users){
//        
        if(empty($users)){
            return false;
        }
        //保存用户
        DB_WEIBO::batch_save($users);
        
        if (!$conn_s = self::$conn) {
            $conn_s = parent::$conn;
        }
        
        //存储微博用户
        foreach ($users as $k => $v) {
            
            //保存到新增粉丝表
            //DB_FOLLOWS_INCREMENT::addRecord($weibo_id, $v['id']);
            
            $follow = ORM_Finder::findOne('DB_FOLLOWS', array('weibo_id'=>$weibo_id, 'follow_id'=>$v['id']), 'id');
            if(!$follow){
                $follow = new DB_FOLLOWS();
                $follow->setWeiboId($weibo_id);
                $follow->setFollowId($v['id']);
                $follow->save();
            }            
        }
    }
}

?>
